test_cases = [
    ("", 1),
    ("A", 2),
    ("B", 2),
    ("AB", 4),
    ("AABBA", 32),
    ("BABAB", 22),
    ("AAABBB", 40)
]

def test_calculate():
    for s, expected in test_cases:
        assert calculate(s) == expected, f"Failed: {s}, expected {expected}, got {calculate(s)}"
    print("All tests passed!")